<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Seo extends CH_Controller{

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	 /**
         * Constructor
         */
	function __construct() { 
		parent::__construct(); 
		$this->init();
		$this->load->model('seo_model');
    } 
    	
    /**
     * SEO정보 설정
     *
     * @access	public
     * @return	result
     */
    function seoInfo(){
    	login_admin();
    	$url = $this->common_model->get_index_uri(2);
    	$uri_array = segment_explode($this->uri->uri_string());
    	$method = (in_array('method', $uri_array)) ? $this->security->xss_clean(url_explode($uri_array, 'method')) : 'keyword'; 
    	$_title = ($method == 'script') ? '통계수집스크립트' : '키워드 설정';
    	$data = array(
    			'_title' => $_title,
    			'_group' => 'seo',
    			'_content' => $this->config->item('ch_manager_root').'/'.$url,
    			'_method' => $method
    	
    	);
    	
    	$data = array_merge($data,$this->seo_model->select_seo());
    	return $data ;
    }

	/**
	 * SEO 정보 DB 처리
	 *
	 * @access	public
	 * @return	result
	 */
	function seoDbjob(){
		$dbjob = $this->input->post('dbjob');
		$method = $this->input->post('method');
		switch($dbjob){
			case('i'):
				$msg = '저장되었습니다.';
				$data = array(
						'title' => $this->input->post('title') ,
						'keyword' => $this->input->post('keyword') ,
						'description' => $this->input->post('description'),
						'script' => $this->input->post('script')
				);
			break;
			case('u'):
				$msg = '수정되었습니다.';
				$data = array(
						'title' => $this->input->post('title') ,
						'keyword' => $this->input->post('keyword') ,
						'description' => $this->input->post('description'),
						'script' => $this->input->post('script')
				);
			break;
			case('d'):
				$msg = '삭제 되었습니다.';
				$data = array(
						'seo_id' => $this->input->post('id')
				);
			break;
		}
		$this->seo_model->seo_dbjob($data);
		$this->alert->jalert($msg, base_url('/seo/seoInfo/method/'.$method));
	}
}

/* End of file html.php */
/* Location: ./application/controllers/seo.php */